package com.education.user.service;


import com.education.user.mapper.SysAppUserMapper;
import com.education.user.pojo.SysAppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author: ly
 * @create: 2018-07-05 15:55
 **/
@Service
public class SysAppUserService {

    @Autowired
    private SysAppUserMapper sysAppUserMapper;


    //根据主键查询
    public SysAppUser selectByPrimaryKey(Integer userId) {
        return sysAppUserMapper.selectByPrimaryKey(userId);
    }

    //条件查询用户信息
    public List<SysAppUser> select(SysAppUser sysAppUser) {
        return sysAppUserMapper.select(sysAppUser);
    }

    //添加用户信息
    public void insert(SysAppUser user) {
        sysAppUserMapper.insert(user);
    }

    //根据主键修改用户信息
    public Integer update(SysAppUser user) {
        Example example = new Example(SysAppUser.class);
        example.createCriteria().andEqualTo("id",user.getId());
        return sysAppUserMapper.updateByExampleSelective(user,example);
    }

    /**
     *  进行关联查询 学校名 和 班级名
     */
    public List<SysAppUser> selectAppUserList(SysAppUser appUser){
        return sysAppUserMapper.selectAppUserList(appUser);
    }

    /** 查详情以及进行关联 */
    public SysAppUser selectOneAppUser(SysAppUser appUser){
        return sysAppUserMapper.selectOneAppUser(appUser);
    }

    /**
     *  删除用户
     */
    public int deleteById(Integer id){
        return sysAppUserMapper.deleteByPrimaryKey(id);
    }
}
